/**
 * 
 * @deprecated 暂时无用
 * 使用示例
 * const worker = new SharedWorker("worker.js");
 * worker.port.start();
 * // 存储对象
 * worker.port.postMessage({ action: "set", key: "user", value: { name: "Alice", age: 25 } });
 * // 获取对象
 * worker.port.postMessage({ action: "get", key: "user" });
 * worker.port.onmessage = function(event) {
 *   console.log("收到数据:", event.data);
 * };
 */
const sharedData = {}; // 存储共享数据
self.onconnect = function(event) {
    const port = event.ports[0];
    port.start();

    port.onmessage = function(e) {
        const { action, key, value } = e.data;

        if (action === "set") {
            sharedData[key] = value; // 存储数据
        } else if (action === "get") {
            port.postMessage({ key, value: sharedData[key] }); // 发送数据
        }
    };
};
